question

Nagaraj avatar image
Nagaraj asked

IS this convert(varchar(50),TamsAttendance.AttdDate,101)='12/13/2007' Possible in SQL server?

convert(varchar(50),TamsAttendance.AttdDate,101)='12/13/2007'

In above query, TamsAttendance.AttdDate is Date field in my table. In that table, Date format is 12/13/2007 10:36:08 PM. I need to check, which is assigned in above query format.

Can anyone help?

sql-server-2005
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Squirrel 1 avatar image
Squirrel 1 answered

it is possible but it will be better if you do this

where TamsAttendance.AttdDate >= '20071213'            
and   TamsAttendance.AttdDate <  '20071214'            
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bill Dean avatar image
Bill Dean answered

It is possible, but it might be easier to compare dates.

WHERE TamsAttendance.AttdDate BETWEEN CONVERT(datetime,'12/13/2007') AND CONVERT(datetime,'12/14/2007')

You should use a range because TamsAttendance.AttdDate may possibly include a time component.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mushtaque Inamdar avatar image
Mushtaque Inamdar answered

Try to use this format it will work all time

'13 Dec,2007' and < '14 Dec,2007'

inamdar_m@hotmail.com mushtaque

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.