简体   繁体   中英

How to calculate no of days based on dates

so this is regarding the picture below where the flights are flying from origin and destination. What I am unable to understand is how the days are calculated, meaning how we are saying that a flight is flying on Monday or Tuesday or Web etc based on the picture below.

Have you even tried googling?

The DateTime class has a format setting for getting the Day of the Week: (Google Search: "get the weekday from date c#") https://learn.microsoft.com/en-us/do.net/standard/base-types/how-to-extract-the-day-of-the-week-from-a-specific-date

If its because you mean to calculate it in general, then: (Google Search: "calculate the day of the week for any date") https://www.almanac.com/how-find-day-week

You can use the following SQL query to return the day of the week:

SELECT DATENAME(WEEKDAY, GETDATE());

Syntax: DATENAME(interval, date)

It will return the day of the week written out.

If you are simply trying to determine how many days between the dates you can use the SQL DATEDIFF function:

SELECT DATEDIFF(day, '2017/08/25', '2011/08/25');

Syntax: DATEDIFF(interval, date1, date2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM