Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am Working with report default date is yesterday date from text box .While running report it is retrieving one day before data.
Example :- 14-07-2021
it is retrieving data 13-07-2021

when connect locally with connection string no such issue.Data retrieving correctly.
When it deployed in server and run this issue happening.Is it by time zone issue.
How can it solved.Server time zone
Mountain Standard Time

I tried various ways data is coming only yesterday day.If I try to add one with this date .It will be problem.I need permenant solution.

What I have tried:

DateTime snapshotDateUtc = snapshotDate.ToUniversalTime().AddHours(5).AddMinutes(30);
            //TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
            //DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, tzi);


It is not correct .I just put some comment here.
Posted
Updated 15-Jul-21 4:57am
v2
Comments
SeeSharp2 15-Jul-21 8:53am    
There is not enough information here for us to tell you what is wrong. We do not know what the WHERE clause looks like in your SQL. We don't know what value is being passed and where. You have to do some troubleshooting to find out where it is breaking down and then you can fix it.
Rob Philpott 15-Jul-21 10:37am    
Sounds like timezones alright. Dates and times can be more confusing than people think. Could you tell us your geographical position and timezone and is the server located nearby or far away and in which timezone?
saifulhaque 15-Jul-21 10:58am    
Yes it is far

My sql query procedure

SELECT	ISH.BinLocation AS [BinLocation], I.ItemName, I.[Description], ISH.QuantityInStock, 
		CAST(
				(
					CAST(I.BoxLength AS DECIMAL) * CAST(I.BoxHeight AS DECIMAL) * CAST(I.BoxWidth AS DECIMAL) * CAST(ISH.QuantityInStock AS DECIMAL)
				) 
				/ @CubicInchToCubicFeetConversionFactor
				AS DECIMAL(18,2)
			) 
		AS [ItemVolumeCF],
		I.BoxLength, I.BoxHeight, I.BoxWeight, I.StatusEnum,ISH.SnapshotDate 
FROM Item AS I
inner join InventorySnapshot AS ISH ON I.Id =ISH.ItemId
and ISH.SnapshotDate=CAST(@SnapshotDate AS DATE)
<pre lang="SQL"><pre lang="SQL">


I am passing date from MVC view .date part only.
When I am checking with locally connected with web.cofig it is working fine.
When I published to server rows are coming before one day.

Time zone mountain standard time


If I try to add one day with date inside code it is working.I think it is because of time diffrence.How we can solve this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900