[SOLVED]using datetime to get info from database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

[SOLVED]using datetime to get info from database

Post 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
Last edited by ryuuka on Tue Nov 07, 2006 3:02 am, edited 2 times in total.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

you should wrap your date with quotes or use mysql's date/time functions
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply