datetime

How to format date on MS SQL Server 2008

∥☆過路亽.° 提交于 2021-02-16 05:10:21
问题 I would like to format dates based on a pattern like for example 22/01/2015 or 2016-12-15. In the .NET Framework we have DateTime -> ToString() method which accepts formats as argument or even string.Format, which does the same. Is there any function on MS SQL Server 2008 that formats date based on a argument pattern? 回答1: I had a similar problem in SQL 2012 they have a great function called format which you could pass in a date and the format you require SELECT FORMAT(GETDATE(), 'dd/mm/yyy')

How to format date on MS SQL Server 2008

人走茶凉 提交于 2021-02-16 05:09:00
问题 I would like to format dates based on a pattern like for example 22/01/2015 or 2016-12-15. In the .NET Framework we have DateTime -> ToString() method which accepts formats as argument or even string.Format, which does the same. Is there any function on MS SQL Server 2008 that formats date based on a argument pattern? 回答1: I had a similar problem in SQL 2012 they have a great function called format which you could pass in a date and the format you require SELECT FORMAT(GETDATE(), 'dd/mm/yyy')

Highlighting weekends in small multiples

江枫思渺然 提交于 2021-02-15 05:33:17
问题 How can I highlight weekends in a small multiples? I've read different threads (e.g. (1) and (2)) but couldn't figure out how to implement it into my case, since I work with small multiples where I iterate through the DateTimeIndex to every month (see code below figure). My data Profiles is for this case a time-series of 2 years with an interval of 15min (i.e. 70080 datapoints). However, weekend days occuring at the end of the month and therefore generate an error; in this case: IndexError:

How to set two time formatters in matplotlib?

China☆狼群 提交于 2021-02-15 05:27:07
问题 This chart is built by Excel. How can I do the same using matplotlib? I mean how to add two formatters: years months. Now i use something like this: fig, ax = plt.subplots(1,1) ax.margins(x=0) ax.plot(list(df['Date']), list(df['Value']), color="g") ax.xaxis.set_major_locator(matplotlib.dates.YearLocator()) ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y')) plt.text(df["Date"].iloc[-1], df["Value"].iloc[-1], df["Value"].iloc[-1]) plt.title(title) plt.get_current_fig_manager()

How to set two time formatters in matplotlib?

孤者浪人 提交于 2021-02-15 05:26:22
问题 This chart is built by Excel. How can I do the same using matplotlib? I mean how to add two formatters: years months. Now i use something like this: fig, ax = plt.subplots(1,1) ax.margins(x=0) ax.plot(list(df['Date']), list(df['Value']), color="g") ax.xaxis.set_major_locator(matplotlib.dates.YearLocator()) ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y')) plt.text(df["Date"].iloc[-1], df["Value"].iloc[-1], df["Value"].iloc[-1]) plt.title(title) plt.get_current_fig_manager()

How to remove timezone when convert from Date to DateTime

纵饮孤独 提交于 2021-02-11 17:19:27
问题 I have a Date get from Database and I want convert it to DateTime and set it to begin day. I write it below: Date fromDate = studentDateJoin.getDate(); //result: fromDate = Mon Jan 01 00:00:02 ICT 2018 //convert to DateTime DateTime newDate = new DateTime(fromDate); But when I convert it add time zone after convert. newDate look like : newDate = 2018-01-01T14:13:04.574Z+7 I have a question: How to convert it to begin day and remove timezone: Example I want to convert it look like: //Convert

Snowflake External Table failed to cast variant value NULL to DATETIME/TIMESTAMP_NTZ type

有些话、适合烂在心里 提交于 2021-02-11 15:45:49
问题 Created an external table with a column of type datetime (TIMESTAMP_NTZ type), the external stage has a csv file with null value in the column. Selecting from the external table is giving "Failed to cast variant value "null" to TIMESTAMP_NTZ" CREATE OR REPLACE EXTERNAL TABLE ext_table_datetime ( col1 datetime as (value:c1::datetime) ) with location = 's3://bucket_name' file_format = file_format_1 auto_refresh = true; Also I have the file format defined as follows, which works for other column

Get current GMT offset from a timezone identifier

浪尽此生 提交于 2021-02-11 15:37:20
问题 How do I get the current GMT offset from a timezone identifier? Ideally, it would include the long form name too. For example: "America/Los_Angeles" //output: GMT-0700 (Pacific Daylight Time) It would be nice if it worked with ISO strings too, for example: 2020-12-21T03:57:00Z //output: GMT-0800 (Pacific Standard Time) 回答1: You can use the timeZone and timeZoneName options of the Intl.DateTimeFormat object as below to get the name of more common timezones, but lesser known ones will probably

Get current GMT offset from a timezone identifier

本秂侑毒 提交于 2021-02-11 15:36:13
问题 How do I get the current GMT offset from a timezone identifier? Ideally, it would include the long form name too. For example: "America/Los_Angeles" //output: GMT-0700 (Pacific Daylight Time) It would be nice if it worked with ISO strings too, for example: 2020-12-21T03:57:00Z //output: GMT-0800 (Pacific Standard Time) 回答1: You can use the timeZone and timeZoneName options of the Intl.DateTimeFormat object as below to get the name of more common timezones, but lesser known ones will probably

Extracting year from datetime datatypes is giving output as float

江枫思渺然 提交于 2021-02-11 15:30:20
问题 I'm a newbee in Pandas. I need your support in a problem i'm facing I have a datatime column in a dataframe and I'm trying to extract the year from it but the output it is giving is in float? fifa['Joined_date'].head() 0 1970-01-01 1 1970-01-01 2 1970-01-01 3 1970-01-01 4 1970-01-01 Name: Joined_date, dtype: datetime64[ns] fifa['Joined_date'].dt.year 0 1970.0 1 1970.0 2 1970.0 3 1970.0 4 1970.0 Name: Joined, Length: 18207, dtype: float64 Output Expected is --> 1970 Can you please help? 回答1: