Link to home
Create AccountLog in
Avatar of ronipats
ronipats

asked on

asp.net, sqlserver date problems

i have an issue with working with dates in asp.net and sqlserver.

I want to send current date from asp.net webform to stored procedure written in sql sever. In stored procedure i want to compare current date if it falls between predifned date range stored in one of my table and return true or false based on that to asp.net webform.

Now i am confused as which data type i should take in database table for date field. if i take datetime then, time (00:00:00) is also been stored in field values and am not able to compare the dates.

is there any way that i can only store date in table and also fetech on date in asp.net from now() function.

please send me solution or example link

thanks
Avatar of duttcom
duttcom
Flag of Australia image

My understanding is that the 00:00:00.000 time in the date field is just ignored if you only refer to the date in your queries. It might be there, but SQL knows it isn't part of the date.

I'm just working on a view that refers to datetime column where all the dates are in the format "2013-07-18 00:00:00.000". I have a filter on that column which is >= '1/01/2013' that works perfectly - the time is irrelevant.

The date field type will also keep only the date portion - you could try that if it really bugs you that the time is there.
Avatar of ronipats
ronipats

ASKER

not able to solve the problem.

I am designing one registration page with birthdate (in asp.net c#). for entering birthdate i have taken textbox and calender control. When i select a date from calender, i convert that date in (dd/MM/yyyy) format to display in text box.

In sql server2008 i have taken datatype of birthdate field as date (in which date is store in yyyy-dd-mm format).

How to convert birthdate text values in database format and insert. please help with sample code.

Also help in howto fetch date from table in display in birthdate textbox in dd/mm/yyyy format.
Avatar of Rob
Your datepicker should have a format option for both displaying on screen and for sending to the server.  What plugin are you using for that?
no i havent used any plugin, i simply used convert and parse function. Do i need to use any sort of plugin???
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer