i have database server located in u.s. user makes entry india date must stored of client , not server. but, unfortunately server date stored in database. showing entries user of current date made on day only. problem when user enters record till 12:30 pm(client machine) being displayed user after 12:30pm (client machine), entries not being displayed entries made after 12:30 pm(client machine) displayed.any idea?
eg: entry done @ 06/05/2013(dd/mm/yyyy) till 12:30 pm shown when client machine date 06/05/2013 11:57 when client machine date 06/05/2013 12:57 pm entries enterd not displayed entries made after 12:30 pm displayed. in db above eg. created date stored 05/05/2013 don't know why? in .cs file:
public static datetime getindiandate(datetime datetime) { return timezoneinfo.converttimebysystemtimezoneid(datetime, timezoneinfo.local.id,"india standard time").date; }
to show todays entries only:
shipments = bll.getshipmentsbyuseridndate(userid, classes.common.getindiandate(datetime.now.date)); public static list<shipment> getshipmentsbyuseridndate(guid userid, datetime datetime) { entities db = new entities(); list<shipment> shipments = (from s in db.shipments s.userid == userid && s.createddate == datetime select s).tolist(); return shipments; }
while inserting:
shipment.createddate = classes.common.getindiandate(datetime.now.date); public static datetime getindiandate(datetime datetime) { return timezoneinfo.converttimebysystemtimezoneid(datetime, timezoneinfo.local.id,"india standard time").date; }
so, how store date of client machine? still stores servers date only.
help appreciated!
hey same recommend store utc date time of every record when saving records.
when fetching records please timezone , manipulate utc date
select getutcdate() --get utc date select getdate()--get indain standared date select dateadd(minute,30,dateadd(hour,5,getutcdate())) --get indian offset +05:30
if want update date c# code please refer one.but in case required utc date
string utcdatestring = system.datetime.utcnow.tostring(); datetime localdate = datetime.parse(utcdatestring, cultureinfo.currentculture, datetimestyles.assumeuniversal);
hop helps you.
Comments
Post a Comment