I all.
In a talbe I've a datatime field. for example it contain '16-4-2007 10:45'.
I like to write a SQL that return all record with the date field equals '16-4-2007' (it's not important the time). how to?
thank you.
Try this query to retrive data
select
*from clientswhere clientAddressbetween'2007-04-12 00:00:00.000'and'2007-04-12 23:59:59.999'The alternative query is
select
*from clientswhere clientAddress>='2007-04-12'and clientAddress<'2007-04-13'The time format is yyyy-MM-dd and time. Since you are saving time in DB the query should be framed as above
Hope this will help you
|||try this syntax
how it works: convert string to date time with correct format for date string and next convert date time back to string with format you need.
See help for CONVERT in T-SQL help for more format info.
No comments:
Post a Comment