Skip to main content
Inspiring
April 10, 2008
Question

SQL: comparing date with datetime field

  • April 10, 2008
  • 3 replies
  • 336 views
I'm having a brain fart as I assume this is really simple.

Given that I have the date in the format of yyyy/mm/dd, how do I put that
into a sql query that compares that to the datetime field?

It appears the datetime field, by default, uses this format: m/d/yyyy
hh:mm:ss am

-Darrel


This topic has been closed for replies.

3 replies

Inspiring
April 11, 2008
If your date formats are different you will have to use CAST or CONVERT
functions as you state you already have. If this works then stick with it.
You may also need to use a SET DATEFORMAT command. See below:

http://msdn2.microsoft.com/en-us/library/ms189491.aspx

Dates in SQL Server can be a bit of a pain to work with. It is usually best
practice to store your DateTime data in raw format and use CAST or CONVERT
functions in your Stored Procs to get the correct results.

Pat.

"darrel" <notreal@nowhere.com> wrote in message
news:ftloim$jv4$1@forums.macromedia.com...
>
>> What dbms?
>
> t-sql (MSSQL)
>
> For now, via string functions, I rearrange the date/time format manually,
> and then use the CAST statement in the SQL query. Not pretty, but seems to
> work.
>
> -Darrel
>


Inspiring
April 10, 2008

> What dbms?

t-sql (MSSQL)

For now, via string functions, I rearrange the date/time format manually,
and then use the CAST statement in the SQL query. Not pretty, but seems to
work.

-Darrel


Inspiring
April 10, 2008
On 10 Apr 2008 in macromedia.dreamweaver.appdev, darrel wrote:

> I'm having a brain fart as I assume this is really simple.
>
> Given that I have the date in the format of yyyy/mm/dd, how do I put
> that into a sql query that compares that to the datetime field?
>
> It appears the datetime field, by default, uses this format:
> m/d/yyyy hh:mm:ss am

What dbms?

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php