School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,153 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,958 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 Rate Topic: -----

#1 kunkka  Icon User is offline

  • D.I.C Head
  • PipPip
  • Group: Members
  • Posts: 99
  • Joined: 15-May 09


Dream Kudos: 0

Posted 31 May 2009 - 04:18 AM

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
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
Was This Post Helpful? 0
  • +
  • -


#2 Robin Marsh  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 07-May 09


Dream Kudos: 0

Posted 31 May 2009 - 07:26 AM

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.
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



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