logo
Tags down

shadow

SAS macro date variable to convert into yyyy-mm-dd format for SAS HiveQL


By : user2175817
Date : October 14 2020, 02:24 PM
Does that help For night owls, automatic macro variable sysdate is the date on which the SAS session started. A long running session might want to use the function today() to get the current date.
Remote pass-through date literals will also need to be single quoted.
code :
%let   remoteDateLiteralForPassThrough = %str(%')%sysfunc(putn(%sysfunc(today()),yymmdd10.))%str(%');
%put &=remoteDateLiteralPassThrough;

%let   remoteDateTimeLiteralForPassThro = %str(%')%sysfunc(putn(%sysfunc(today()),yymmdd10.))T0:0:0%str(%');
%put &=remoteDateTimeLiteralForPassThro;
%let start_date_num = %sysfunc(intnx(month, %sysfunc(today()), -1, B));
%let db_start_date = %str(%')%sysfunc(putn(&start_date_num,yymmdd10.))%str(%');


Share : facebook icon twitter icon

convert date in excel from dd-mm-yyyy to dd/mm/yyyy format and to check whether a date is valid or not


By : cynthia lesnik
Date : March 29 2020, 07:55 AM
With these it helps First, I suggest you check the regional settings for dates on your computer. If you set it to use the "dd/mm/yyyy" format it will be used by Excel as well and hopefully remove the need for any RegEx VBA-code.
Second, if you do need to use VBA to reformat dates, I strongly suggest you use the Date data type instead of Variants. I also advise you to use Option Explicit at the top of your code and explicitly declare any variables in order to minimize typos and produce better quality code.

Teradata: how to convert varchar value (format 'dd.mm.yyyy') to date (format 'yyyy-mm-dd' )?


By : Jknapper66
Date : March 29 2020, 07:55 AM
will help you how to convert varchar value, containing date in dd.mm.yyyy format, into date format 'yyyy-mm-dd' in WHERE clause in Teradata ? Need to code something like this: , You need to apply a format during the cast, either Teradata style:
code :
WHERE CAST(str AS DATE FORMAT 'dd.mm.yyyy') 
BETWEEN DATE '2015-06-01' AND DATE '2017-12-31'
WHERE TO_DATE(str, 'dd.mm.yyyy') 
BETWEEN DATE '2015-06-01' AND DATE '2017-12-31'

How to convert string of different format(YYYY-MM-DD, DD-MM-YYYY) to date object of one format in pandas?


By : Nitin Sharma
Date : March 29 2020, 07:55 AM
Does that help Let pandas to parse dates, but then some days with months should be swapped:
code :
df['accepted_date'] = pd.to_datetime(df['accepted_date'])
df = pd.DataFrame({'accepted_date':['2017-01-02','07-08-2017','20-03-2017','2017-01-04']})

d1 = pd.to_datetime(df['accepted_date'], format='%d-%m-%Y', errors='coerce')
d2 = pd.to_datetime(df['accepted_date'], format='%Y-%m-%d', errors='coerce')

df['accepted_date1'] = d1.combine_first(d2)
df['accepted_date2'] = pd.to_datetime(df['accepted_date'])
print (df)
  accepted_date accepted_date1 accepted_date2
0    2017-01-02     2017-01-02     2017-01-02
1    07-08-2017     2017-08-07     2017-07-08 <-swapped dd-mm
2    20-03-2017     2017-03-20     2017-03-20
3    2017-01-04     2017-01-04     2017-01-04
print (d1)
0          NaT
1   2017-08-07
2   2017-03-20
3          NaT
Name: accepted_date, dtype: datetime64[ns]

print (d2)
0   2017-01-02
1          NaT
2          NaT
3   2017-01-04
Name: accepted_date, dtype: datetime64[ns]
df['accepted_date3'] = pd.to_datetime(df['accepted_date'], dayfirst=True)
print (df)
  accepted_date accepted_date3
0    2017-01-02     2017-01-02
1    07-08-2017     2017-08-07
2    20-03-2017     2017-03-20
3    2017-01-04     2017-01-04

How to convert a date a user selects in MM-dd-yyyy format to the format yyyy-MM-dd in Java


By : ImoLR
Date : March 29 2020, 07:55 AM
should help you out You said, you want to convert a date with a given format, but you don't have a parameter for that.

Convert date format of string to datetime MM/dd/yyyy when system date formate is dd/MM/yyyy


By : renGth
Date : March 29 2020, 07:55 AM
wish of those help DateTime stores a date as a numerical value, not as a string. So asking for a DateTime type of format 'MM/dd/yyyy' doesn't make much sense. If you are displaying the date in a WPF control, it will default to displaying a string that conforms to the system date format. But that is just a display string that you can manipulate using the format strings alluded to in the links above. Using @Sajeetharan's code will create a DateTime struct with the correct value internally. How you display it is up to you and your string formatting choices.
The same goes for dates stored in a database column of type 'datetime'. The value is stored numerically. Your query editor will display the value likely in the same format as your system settings. If the date is stored as a string, then again, @Sajeetharan's code is the correct way to convert the database string into a DateTime struct.
shadow
Privacy Policy - Terms - Contact Us © voile276.org