Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a string to a date in sybase

I need to specify a date value in a sybase where clause. For example:

select * 
from data
where dateVal < [THE DATE]
like image 518
cmsherratt Avatar asked Sep 11 '08 11:09

cmsherratt


2 Answers

Use the convert function, for example:

select * from data 
where dateVal < convert(datetime, '01/01/2008', 103)

Where the convert style (103) determines the date format to use.

like image 126
cmsherratt Avatar answered Oct 10 '22 17:10

cmsherratt


Here's a good reference on the different formatting you can use with regard to the date:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/Convert.htm

like image 32
Edwin Avatar answered Oct 10 '22 18:10

Edwin