Page 1 of 1

[SOLVED]using datetime to get info from database

Posted: Tue Sep 26, 2006 2:00 am
by ryuuka
good day again

as you see below this is in combination with my last post (will delete that in a moment)
what i want to do is using lastcheck to get every single bit of information from a single day.
my current query also does that but wth that i get every thing from today using the TOP command.
what is a better way of doing this?

i tried a lot of different stamps but they won't work because i get something like:
error trying to convert datetime to char or something

this is the format i get this in: 26-9-2006 8:56:30
this is what i got right now:

Code: Select all

SELECT top 288 Lastcheck, ServerName, TotalPhysicalMemorySize, TotalVirtualMemorySize, FreeVirtualMemory, FreePhysicalMemory
                                  FROM @@@@_Server_Memory_used
                                  WHERE (ServerName LIKE 'sr0029') AND (Lastcheck = 26-9-2006)
                                  ORDER BY Lastcheck DESC

Posted: Tue Sep 26, 2006 2:12 am
by wtf
you should wrap your date with quotes or use mysql's date/time functions

Posted: Tue Sep 26, 2006 2:15 am
by ryuuka
how would i go about doing that? correctly anyway
tried to use the quotes but that won't work properly

and another thing i forgot to mention: i don't use MySQL i use MSSQL

thanks

Posted: Tue Sep 26, 2006 3:54 am
by volka
Lastcheck = 26-9-2006
I'm not familiar with mssql but I'm quite sure you have to mark the literal in some way, like '2006-09-26'.
Maybe you even have to cast() the string explicitly to a date/time type.