質問

i'm working on a microsoft access DB with a column with values in the format Jan-2013, Feb-2014, May-2015.

Is it possible to convert those values to a valid datetime value from an Access select query? Only the month and year are important so day can be taken as just the first day of the month specified.

役に立ちましたか?

解決

This works in Russian locale, so i suppose English will be good too:

cdate("01-" & [FieldWithMM-YYYY])

他のヒント

Since your fine using the first day of the month you can use DateValue to tag "the first" to the start of your existing string

Dim newDate as Date
newDate = DateValue("01-" & yourDateColumn)

or

Select DateValue("01-" & yourDateColumn) as FormattedAsADateNow
From yourTable

If you have nulls you'll need to protect against those or this will give a Type Mismatch.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top