Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
653 views
in Technique[技术] by (71.8m points)

sql - Convert String to Date in MS Access Query

I am trying to retrieve data from my access table based on Date column. My requirement is to display everything greater than the certain value. I am trying to cast my value, which is a string using Format &CDate function with datetime data type and it throws out as Overflow.

Here's query :

Select * from Events
Where Events.[Date] > cDate(Format("20130423014854","yyyy-MM-dd hh:mm:ss"))

Sample Date Record Value from Table : 2013-04-23 13:48:54.0

Events.[Date] is a Date/Time type field in access

How can I fix this ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the DateValue() function to convert a string to date data type. That's the easiest way of doing this.

DateValue(String Date) 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...