Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Retrieving records for the current date only

Author  Topic 

kiesh
Starting Member

6 Posts

Posted - 2009-11-13 : 00:20:05
Here my situation:
-i have a table which includes a date column that is formatted as dd/mm/yyyy, no time is used.

-Users usually create whatever it is via a form, and select a date, in the format mentioned, this info is then added to table in the database.

-What i want is to display only the records of the current date on my pc, i say this, because i want to be able to change my pc date and it pulls only those records of that date, hence current date.

-I thought it would be as simple as using some like this:

select * from tablename where datecolumn=getdate() but i keep getting this error:

ERROR 1305 (42000): FUNCTION dbname.getdate does not exist

A solution would be greatly appreciated, and preferably with an example.
Thank you!

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-11-13 : 00:32:12
r u using mssql or oracle?
if ur using oracle use sysdate function
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-13 : 01:00:46
MySQL ? FYI this is a Microsoft SQL Server forum


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kiesh
Starting Member

6 Posts

Posted - 2009-11-13 : 01:36:57
i am using mysql
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-11-13 : 01:53:45
i think u have to use now() function........... in mysql
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-11-13 : 02:12:33
Excatly in mysql

select * from table_name where date(column_name) =date(now())

Better use http://forums.mysql.com/



Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-13 : 02:12:55
quote:
Originally posted by kiesh

i am using mysql


select * from tablename
where datecolumn>=current_date() and datecolumn<adddate(current_date() ,interval 1 day)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kiesh
Starting Member

6 Posts

Posted - 2009-11-14 : 12:22:39
Thsk alot guys for you help. got it to work!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-16 : 01:35:14
quote:
Originally posted by kiesh

Thsk alot guys for you help. got it to work!


But keep in mind that this site is specifically form MS SQL Server and not mysql.

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -