ADS retrieve whenchanged with AM or PM - vbscript

I have a vbs file that queries the domain as below
queryTxt = "<"& domainname &">;" & _
"(&(objectclass=user)(objectcategory=person));"
queryTxt = queryTxt & "SAMAccountName,whenchanged"
But in some servers "whenchanged" is returning values as "8/18/2014 1:20:30 AM" and in some as "12-08-2014 04:54:58". I want to have the returning value as the first date format.
How to update the query so that I get a unique date format.

Queries to the whenChanged attribute return a Date value, so the display format is governed by the regional settings of the computer displaying the query results. Either change the date format in the computer's regional settings, or use a StringBuilder object for building a custom date format.

Related

Facing issue with Date column format in Power BI

I have an excel dateset where date column includes date in dd-mm-yyyy format(Proper date) and in text format that too in mm/dd/yyyy format(just text not proper date). want to convert all dates in dd-mm-yyyy format. How to do all in dd-mm-yyyy format in Power Query editor
The question is: In Power Query Editor Perform all necessary action to convert all the dates in the "Date" column to be in "dd-mm-yyyy" format.
I am new in Power BI. Please help on this.
enter image description here
Importing correctly
If you set the right culture, all the inputs are converted to a type date
let
Source = #table(
type table[Date = text],
{ {"7/27/2012"}, {"9/14/2020"}, {"04-11-2020"} }
),
// using the system's current culture
#"Dates" = Table.TransformColumnTypes(
Source,
{ {"Date", type date} }
),
//specify a specific culture
#"US Dates" = Table.TransformColumnTypes(
Source,
{ {"Date", type date} },
"en-US"
)
in
#"US Dates"
date verses text
I'm not clear if you're referring to different date format strings, or actual data types when you say Proper Date, I think you mean the first.
In the query editor where you import dates, it should be type date
If it visually displays out of order, that's okay. It's using your systems current settings.
Once you're in the data model, that is when you pick your date format strings. Notice that both images use the same data, the green is the data type in Power Query.
Blue is the format string that lets you override the defaults.

If Else Formula for Date field in Crysal Reports that keeps Date format - not string

I have a formula in Crystal Reports to convert for a particular date. The formula is working, but converts the field to a string, and I need the field to be a date as I am exporting as a CSV file and then loading data to a table.
Is there a way to use this same logic but have the field remain as a date
and not a string? Below is the current logic that I am using:
if totext((Date(Year({Command.RENEWAL_DT}), Month({Command.RENEWAL_DT}), Day({Command.RENEWAL_DT}))),'dd/MM/yyyy') = "01/01/1800" then
"01/31/2099"
else
totext((Date(Year({Command.RENEWAL_DT}), Month({Command.RENEWAL_DT}), Day({Command.RENEWAL_DT}))),'MM/dd/yyyy')
Maybe like this
if totext((Date(Year({Command.RENEWAL_DT}), Month({Command.RENEWAL_DT}), Day({Command.RENEWAL_DT}))),'dd/MM/yyyy') = "01/01/1800" then
"DATE '2099-31-12'"
else
"DATE '" & totext((Date(Year({Command.RENEWAL_DT}), Month({Command.RENEWAL_DT}), Day({Command.RENEWAL_DT}))),'yyyy-MM-dd') & "'"
Or use the TO_DATE() function.

Date/Time error when entering into azure incorrectly

I'm trying to add 2 DateTime fields which are stored as strings in Azure. The first datetime is supposed to get the current date and time now and this stores the date time as 12/02/2019 09:01 correctly, but currently the second field is supposed to get the current date and time and add 30 minutes but it is storing is like only the date eg 12/02/2019. This is my current code:
symptomFeedback.DateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
symptomFeedback.Datetimelimit = DateTime.Now.AddMinutes(30).ToString("dd/MM/yyyy HH:mm");

Lotus sorting view on orderdate does not work properly

I have created a view in which I also have a column which holds dates. This column can be sorted on ascending and descending. This is my column properties value:
But the problem is that the view does not sort the dates properly:
And here a screenshot of the orderdate field itself:
And here screenshot of the document with the orderdate that is out of order in the view:
Update
Some documents had the orderdate as text instead of date.. I create these documents through a java agent. The field orderdate I fill in like this:
SimpleDateFormat formatterDatumForField=new SimpleDateFormat("dd-MM-yyyy");
docOrder.replaceItemValue("Orderdatum",formatterDatumForField.format(currentDateForField));
But it is saved as text instead of date. Anyone knows why?
Problem was that orderdate field was set by a backend agent and this field was set with a string.
I know saved the current time as a DateTime object and now it works:
DateTime timenow = session.createDateTime("Today");
timenow.setNow();
docOrder.replaceItemValue("Orderdatum", timenow);
It's not clear to me why it's not working for you, but you can brute force it with something like this in the column formula
dateForSure := #TextToTime(OrderDatum);
#Text(#Year(dateForSure)) + "-" + #Text(#Month(dateForSure)) + "-" + #Text(#Day(dateForSure));
Also: your Java code saves a text value because the format() method of SimpleDateFormat returns a StringBuffer. The ReplaceItemValue method generates a text item when its input is a String or StringBuffer. Assuming your form defines OrderDatum as a Time/Date field, you can call Document.ComputeWithForm in your code to force it to convert the text item to a Time/Date. Another method - probably preferable given the potential side-effects of calling ComputeWithForm would be to create a DateTime object in your Java code and pass it to the ReplaceItemValue method instead.
It's because formatterDatumForField.format(currentDateForField) returns a String instead of a date/time value. Assuming that currentDateForField is a date/time value, you should change
SimpleDateFormat formatterDatumForField=new SimpleDateFormat("dd-MM-yyyy");
docOrder.replaceItemValue("Orderdatum",formatterDatumForField.format(currentDateForField));
to
docOrder.replaceItemValue("Orderdatum",currentDateForField);

Error while formatting the date variables in sas

I am getting an error when i try to do format for a date variable.
This is how my date variable values look-like "26-Dec-58"
"The format $DATE was not found or could not be loaded"
The reason for the error is that my date value is stored as a char variable in the data set so its not accepting the format of a numeric variable when i am formatting the variable.
So i want to convert my date (which is a character) variable into a numeric variable without introducing a new variable.
I tried datepart and substring options but still getting error.
I am still at the learning stage in sas so any code to clear the error is appreciated i know the concept but coding i tried with all i know but still no luck.
Current code:
data Practice.Sales;
set Practice.Sales;
Birthdate = '26-Dec-58';
Purchase_Dt = '15-Sep-04';
t_num_date = input(Birthdate, ddmmyy8.);
t_num_date1 = input(Purchase_Dt, ddmmyy8.);
drop Birthdate Purchase_Dt;
format Birth_date ddmmyy8. PurchaseDt ddmmyy8. Price DOLLAR10.2;
rename t_num_date = Birthdate;
rename t_num_date1 = Purchase_Dt;
run;
It isn't possible to change an existing variable in a SAS dataset directly from character to numeric. However, you can create a new numeric variable, drop the original character variable, then rename the new one:
data example;
mydate = '26-Dec-58';
t_num_date = input(mydate, date9.);
drop mydate;
format t_num_date date9.;
rename t_num_date = mydate;
output;
run;
N.B. you have to apply the format to the temporary variable before it gets renamed. Attempting to apply a numeric format after renaming it results in an error, as the format statement is processed before the rest of the data step runs, and at that point the original character variable hasn't been dropped yet.
This code works fine for me but still the newly created variables are coming at the last how to change that
data Practice.Sales;
set Practice.Sales;
Birth_date=datepart(input(Birthdate,anydtdtm19.));
PurchaseDt = datepart(input(Purchase_Dt,anydtdtm19.));
format Birth_date PurchaseDt ddmmyy8. Price DOLLAR10.2;
drop Birthdate Purchase_Dt;
run;
You need to use the rename at set statement and then drop them at the end.
data Practice.Sales;
set Practice.Sales
*rename old variables;
(rename=(birthdate=birth_date purchase_dt=purchasedt));
*use renamed variables in code;
Birthdate=datepart(input(Birth_date,anydtdtm19.));
Purchase_Dt = datepart(input(PurchaseDt,anydtdtm19.));
format Birthdate Purchase_Dt date9. Price DOLLAR10.2;
drop Birth_date PurchaseDt;
run;
The variables in a SAS dataset appear in the order they were created.
If you really want to determine the order of the variables yourself, then you should create them before your set statement. Further, I suppose you prefer NOT changing the name of the variables, while still changing their type. Therefore we have to rename the existing variables while reading them.
data Practice.Sales;
format Birthdate Purchase_Dt ddmmyy8. Price DOLLAR10.2;
set Practice.Sales (rename =(Birthdate=oldBirth Purchase_Dt = oldPurchase));
Birthdate=datepart(input(oldBirth,anydtdtm19.));
Purchase_Dt = datepart(input(oldPurchase,anydtdtm19.));
drop Birthdate Purchase_Dt;
run;

Resources