I have a problem with times conversion.
In my database, I have 2018-08-20 08:30:11.000 PM and I can't change this format.
When I use =Fields!DateTime.Value, I display the date like this (it's only example).
But I want to display it in this way (date is ok) 2018-08-20 20:30:11.
I thought about searching this value and when it will be PM then add 12 to hour but it doesnt work... I have no more ideas...
=Format(Fields!DateTime.Value,"MM/dd/yyyy") & Environment.NewLine & iif (Fields!DateTimeValue="PM"), Format(Fields!DtTmStart.Value="HH+12:mm:ss")
Could somebody help me? Please!
The following expression should give you what you need...
=Format(Fields!DateTime.Value,"yyyy/MM/dd HH:mm:ss")
Note the upper case HH, this gives 24 hour format (hh = 12 hour format)
Related
So I am parsing out a large text field with several dates in it. the date format comes out like "44445" which should be "9/6/2021" but when I convert to datetime in Microsoft SQL Server 2019 i get "9/8/2021" I found that every date that I convert is 2 days off. I can of course just do a -2 before converting to make sure I get the right date but I found this really odd and wondered if anyone knew why this was happening and if I am doing something wrong
cast(44445 as datetime) result 2021-09-08 00:00:00.000
if I put the same date in excel I get "9/6/2021" which is the correct date
I found something online about excel calculating 1900 as a leap year and therefore having a different date but excel seems to be correct and SQL statement seems to be wrong so I don't know...
Is anyone able to help me convert the lastLogon and lastLogonTimestamp from Active Directory? I am pulling the data with Power Query and for my own user name I and the data is returned like this:
[users.lastLogonTimestamp]=131804496023891686
[users.lastLogon]=131808141012537325
I found this page on Microsoft Docs which states very clearly:
This value is stored as a large integer that represents the number of
100-nanosecond intervals since January 1, 1601 (UTC). A value of zero
means that the last logon time is unknown.
However I am struggling to get a logical result. I have tried converting nanosecond to days, and then adding the days integer to the starting date '1/1/1601' result. Since I have been actively logging in, I should be getting a date result around today's date, '09/10/2018'.
131804496023891686 / 86,400,000,000,000
= 1525.5150002765241435185185185185
_
1525 + '1/1/1601' = Wednesday, March 6, 1605
-- REFERENCES:
1) https://www.calculateme.com/time/nanoseconds/to-days/
2) https://www.timeanddate.com/date/dateadded.html?m1=01&d1=01&y1=1601&type=add&ay=&am=&aw=&ad=1525&rec=
3) https://learn.microsoft.com/en-us/windows/desktop/adschema/a-lastlogon
Okay so this is a DOH! moment... The answer was staring me in the face. I missed the fact that this was represented in 100 nanoseconds not 1 nanosecond.
(131804496023891686*100) / 86,400,000,000,000
152551.50002765241435185185185185
_
152551 + '1/1/1601' = Thursday, September 13, 2018
NOTE: So this result is actually 3 days in the future... not perfect, but what I am really looking for is just "Active accounts in the last 30 days", so I will consider this acceptably accurate.
This article was also helpful-- http://www.selfadsi.org/ads-attributes/user-lastLogonTimestamp.htm.
So, for PowerShell, I put all together as following
(Get-Date '1601-01-01').AddDays([long]::parse($objItem.lastlogon)*100/86400/1000/1000/1000)
Sorry guys - new to this - complete novice.
I am pulling data from a SQL Server from Excel using Microsoft Query.
I'm currently limiting fields to just invoices within a date range using:
=#10/1/2017# And <#10/31/2017#
My date format is:
2017-10-02 00:00:00.000
I run this report many times during the current month - so I need to change the string above when the new, current month, begins.
I'd love for someone to give me the command that will always pull the current month - regardless of the month - thus allowing me to not have to alter the condition when a new month begins.
Thank you in advance.
The question is not so clear but here is what you can try with:
To find today with date and time:
=NOW()
To find the beginning of the month:
=EOMONTH(A2,-1)+1
To find the end of the month:
=EOMONTH(A2,0)
Let me know if this is what you are expecting.
I am importing information from an Oracle database on an AIX machine into SQL Server 2008r2. I inherited this process from the previous DBA. The timestamp comes in the following format: 4170180534, which, based on the conversion function in the executable, converts to the following:
417 = year (2017)
018 = days since beginning of year (018 converts to Jan 18)
0534 = time HH:mm
I need to provide maintenance on the conversion function (the previous DBA retired in 2016, so the date conversion function only works through the end of 2016).
Can anyone tell me exactly what this timestamp format is? I assume the '4' stands for the century, but it would be nice to know for sure what the first digit of the value actually is.
4should stand for weeks since start of year
format for that would be
(weeks since 1st jan, 2last digits of year, days since 1st jan, hours, minutes)
WW IY DDD HH MI
I have a numeric field in my Oracle database that represents the number of days since Dec 28, 1800. However I am trying to select it (for another application) as the current date it represents. I'm not too familiar with Oracle commands (I'm used to SQL), so I was wondering if anyone could provide some assistance. Thanks.
ex: 77650 = Saturday, August 3, 2013
Firstly, get this out of the way, your life would be easier if you stored dates in a date data-type.
However, to answer your question to add days to a date in Oracle you can use the + operator.
Firstly though you have to have a date so I'll convert the 28th December 1800 into a date using to inbuilt to_date function then add the number. In your case you would want:
select to_date('1800/12/28','yyyy/mm/dd') + 77650 from dual
I've set up a little SQL Fiddle to demonstrate for you.