School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,329 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,840 people online right now. Registration is fast and FREE... Join Now!




how to get today's date. is my code wrong

 

how to get today's date. is my code wrong

kunkka

31 May, 2009 - 04:18 AM
Post #1

D.I.C Head
**

Joined: 15 May, 2009
Posts: 99


My Contributions

i created a table with a column of date with checking whether the selected date is today or a future day

so code for that i put is
CODE
ALTER TABLE Booking
add Booking_date datetime check ((Booking_date=getdate()) or (Booking_date>getdate()))


but when i insert data using vb.net application. it accepts the future dates. but not today's date. y is that. can someone help me to that

User is offlineProfile CardPM
+Quote Post


Robin Marsh

RE: How To Get Today's Date. Is My Code Wrong

31 May, 2009 - 07:26 AM
Post #2

New D.I.C Head
*

Joined: 7 May, 2009
Posts: 13



Thanked: 1 times
My Contributions
Booking_Date uses the 'datetime' data type which has the folloing format...

YYYY-MM-DD hh:mm:ss

If your booking date does not match the sql server (getdate()) date exactly to the second it will return false.

Try using either a date data type or incorporating a between statement in the query.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 03:48PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month