UniData Current Date Function - u2

Is there the equivalent of the sql server getdate() function in UniData? I'd like to be able to query a table like this:
SELECT GETDATE() AS EXPORT_DATE, * FROM TABLE

There are two ways to do this - one that is more "standard", and another more flexible but slightly awkward.
1) Create an I-descriptor that returns the current date like so:
:AE DICT TABLE EXPORT_DATE
001 I
002 DATE()
003 D4/
004
005 10R
006 S
And then
:LIST TABLE EXPORT_DATE
2) Using the Unidata "flavor" of the query language avoids creating a DICT item, but is sort of awkward to type and you need to be in ECLTYPE U (or use the command (list, sort) in lower case to force ECLTYPE U):
:list TABLE EVAL "OCONV(DATE(),'D4/')" COL.HDG "EXPORT_DATE"
Personally, I almost always have a TODAY, COUNTER, CURR.USER etc. DICT item in the main tables used for reporting. You can think of I-Descriptors as little mini-views from a SQL perspective, that only return one column. Here's an interesting set of examples on the possible date formats to return too.

:AE VOC TODAY
001: I
002: DATE()
003: D4/
004:
005: 10R
006: S
By putting it in the VOC, it is now accessible to all files defined in that environment.
You can now LIST TRANSACTIONS WITH TRAN.DATE = TODAY
This will compare a field in the TRANSACTIONS file, TRAN.DATE to the date it is today, which is returned from the date function DATE(). All Pick languages, which UniData is, uses an internal date, which is how many days past 12/31/1967 (The year Dick Pick's daughter was born) The conversion which is on line 3, "D4/" converts that internal date to a MM/DD/CCYY format when displayed. Changing the "/" to a "-" makes it look like MM-DD-CCYY, and changing the 4 to a 2 will change the dates to display with only the significant last 2 digit.

Related

Create Date from MM/DD format and include current year? Power Query

I have a table that has a series of Columns with data I need to split out. Example below
STATUS#10/16 12:00:00 (CODE)
I've been able to split it easy enough and when I originally tried to set the date on an older dataset it identified it as a date e.g. 16th Oct 2021 However I started to get errors on this date column and trying with different datasets (10/12, 10/13, 10/14) it is not finding the date. I tried the following query code but I'm receiving errors
[STATUS DATE] is split to 10/14, 10/15 etc
#date( Date.Year(DateTime.LocalNow), Date.Month(Text.End([STATUS DATE]), 2), Date.Day(Text.Start([STATUS DATE]),2))
However I'm getting a function error so I tried
Date.From(Date.Day(Text.Start([STATUS DATE]),2) & Date.Month(Text.End([STATUS DATE]),2) & Date.Year(DateTime.LocalNow)
I have also tried to do this from an example column however the query created is looking at the cell value e.g. if 10/14 then 14/10/2021 else if 13/10 then 14/10/2021. This method i feel is prone for error once I include a larger dataset.
Is there anyway I can determine the date value based on mm/dd format? But with year end in mind, make the YYYY be determined by current year unless we move into Jan and then I don't want the Oct, Nov, Dec value showing as 2022.
You don't really show what your original data looks like.
But if it is like:
Source
Then you can use this code in the Add Custom Column dialog:
let
split=Text.SplitAny([STATUS DATE],"#/ "),
mnth = Number.From(split{1}),
dy = Number.From(split{2})
in
#date(Date.Year(DateTime.LocalNow()),mnth,dy)
The Text.SplitAny function lets you input a list of delimiters and the text will split on all of them. So it is relatively simple to extract the month and day values
to create:
Split [STATUS DATE] one more time into [Month] and [Day] column, using the "/" as a separator. Then you don't have to bother with 1 or 2 digit numbers and you can simply use this formula:
#date(Date.Year(DateTime.LocalNow()), [Month], [Day])
DateTime.LocalNow() is a function, so you need to add the brackets.
[Month] and [Day] are numbers already, so you don't need the Date.Month() or Date.Day() functions.

Excel Using concatenate to compare dates

I have a table containing several columns of which one is a date/time field. I am trying to get a count of instances per day using the following
=COUNTIFS(Table4[Data],"Apple",Table4[Date],(CONCATENATE(V4,"*")))
Data Date Comp Date Count
Apple 6/12/18 1:00 PM 6/12/18 12:00 AM 0
Apple 6/12/18 7:00 AM
Orange 6/12/18 1:30 PM
Apple 6/11/18 11:23 AM
From my understanding of all the moving parts here I should be checking to see if "Apple" exists in the data column and then if "6/12/18" with any amount or type of characters after it exists. If both are true I will then get a count + 1 leaving me with a value of 2 in the above example.
What I actually get however is a 0 unless I match the time portion of date the data to be exactly the same and then removed the wildcard ,"*" from the equation.
Am I doing something wrong or can the wildcard not be used to accomplish what I am trying?
Thanks!
I think you should set your criteria properly.
If you add an additional column next to your Date that contains calculates the integer value of your date using INT() and format the display as DATE (m/d/yyyy) you should then be able to use the following COUNTIFS formula
=COUNTIFS(Table4[Data], "Apple", Table4[Date], "=6/12/18")
See the explanatory video from their Office' support site: https://support.office.com/en-us/article/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842
If your [Date] column is a datetime or smalldatetime, you can work with it using CONVERT function, depending on how you want to group.
For example, if you don't care about the time to do the group, you could use the next query:
SELECT CONVERT(varchar,[Date],103), [Data], COUNT(*)
FROM [test_delete].[dbo].[Table1]
GROUP BY CONVERT(varchar,[Date],103), [Data]
This should result in something like this:
[Date] [Data] [Count]
11/06/2018 Apple 1
12/06/2018 Apple 2
12/06/2018 Orange 1
Hope this helps you
If your dates are stored as dates instead of text, use the following:
=COUNTIFS(Table4[Data],"Apple",Table4[Date],">="&V4,Table4[Date],"<"&V4+1)

PowerQuery (M): How can I extract a date from a large text field?

My table has a text column called Remarks which usually contains a large amount of text.
Here's an example:
3/24/2017 11:14:41 AM - EMD FOR STATUS NFU 3/30/17
3/30/2017 10:58:03 AM - CLD PER RECEPTIONIST GM UNAVAILABLE NFU 04-13-2017
4/13/2017 11:10:15 AM - CLD PER RECEPTIONIST WILL GIVE INFO NFU4/27
4/27/2017 9:02:20 AM - MLD INV WITH 90 DAY STAMP
4/27/2017 9:15:03 AM - PER REP WILL CALL CUSTOMER FOR PAYMENT
4/27/2017 11:03:46 AM - NFU 05/5PER REP CUSTOMER CONFUSION
5/5/2017 8:55:17 AM - NFU 5/9/2017 CRP PER REP CHECK WAS MLD 5/2/17
All of that text would be crammed into a single field, and I need to extract the last NFU date from the field for use in calculations and filtering.
In the above example, I would want to extract the date 5/9/2017 from the last row.
But as you can see, the date could be in any format, anywhere in the field.
I presume Excel can parse the text into a date value in any of the above formats (if not, I'll deal with that some other way - employee training, etc.)
The main things I need to figure out how to do using PowerQuery are:
Find the last instance of "NFU" in this field
Extract all text immediately following that last instance of "NFU", including the space between "NFU" and the date, if present.
At this point, the result should be:
" 5/9/2017 CRP PER REP CHECK WAS MLD 5/2/17"
Remove any whitepsace at the beginning of the string.
At this point, the result should be:
"5/9/2017 CRP PER REP CHECK WAS MLD 5/2/17"
Find the first character that is not 0-9, /, or - (or the end of the string, whichever comes first)
Truncate the string at the first non-date character, if appropriate.
At this point, the result should be:
"5/9/2017"
Finally, attempt to format the resulting text into Date type/format, and return as the result for a PowerQuery custom column.
Looking at the PowerQuery string functions available, I'm not sure whether this is even possible.
I guess you mean the Power Query Text functions. These are somewhat limited indeed, but there are plenty other options in Power Query's function library: in this case the List functions can come to the rescue.
By the way: I checked for " NFU" in order to avoid "CONFUSION" (last but one line in your examples).
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Typed = Table.TransformColumnTypes(Source,{{"example", type text}}),
LastNFU = Table.AddColumn(Typed, "LastNFU", each Text.PositionOf([example]," NFU",Occurrence.Last), Int64.Type),
AfterNFU = Table.AddColumn(LastNFU, "AfterNFU", each if [LastNFU] = -1 then null else Text.Range([example],[LastNFU]+4)),
Trimmed = Table.TransformColumns(AfterNFU,{{"AfterNFU", Text.Trim}}),
TextToList = Table.TransformColumns(Trimmed,{{"AfterNFU", each if _ = null then {} else Text.ToList(_)}}),
ListFirstN = Table.TransformColumns(TextToList,{{"AfterNFU", each List.FirstN(_, each Text.Contains("01234567890-/",_))}}),
TextCombine = Table.TransformColumns(ListFirstN, {"AfterNFU", Text.Combine, type text}),
Date = Table.TransformColumnTypes(TextCombine,{{"AfterNFU", type date}}, "en-US"),
Renamed = Table.RenameColumns(Date,{{"AfterNFU", "Date"}}),
Removed = Table.RemoveColumns(Renamed,{"LastNFU"})
in
Removed
A simple formula like =RIGHT(A1,LEN(A1)-(FIND("NFU",A1,1)-1)) would work to extract the string next to NFU. Assuming the text is at cell A1.
But needs to further drill down to get your other requirements.

modx getResources tv

I have a page for a sports club based on ModXCMS 2.1.4.
For a list of sport classes I have appr. 30 Documents for the different.
Each of this has template variables like abteilung, Wochentag, Startzeit, etc.
The tv.Wochentag contains Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag as weekdays.
Now my problem:
The output is not sorted by the variable.
Here my code:
[[getResources?
&parents=`19`
&debug=`1`
&tvFilters=`abteilung==[[*abteilung]]`
&sortby=`{tv.Wochentag:"Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag":"ASC",tv.UhrzeitStart:"ASC"}`
&tpl=`snipSportangebot`
&includeTVs=`1`
&tvPrefix=``
&limit=`0`
&processTVs=`1`]]
Finaly I would like to sort by Wochentag (Weekday) and StartZeit (Starttime/Time).
What have I done wrong?
Has anyone any hint on this.
Thanks in advance
Christian
Join weekday and starttime to one TV - Input Type: Date, then you will be able to sorting by TV in getResources:
sortbyTV - Template Variable to sort by
sortdirTV - Order which to sort by when using sortbyTV
sortbyTVType - Specify the data type of the sortby TV. Possible values are string, integer, decimal, datetime
https://rtfm.modx.com/extras/revo/getresources
Youy cannot sort by a TV using sortby [see the docs] if you try to use sortbyTV & sortdirTV it's going to sort them alphabetically for you.
set your day of the week tvs values to numeric :
Montag==0||Dienstag==1||Mittwoch==2||Donnerstag... etc
then your sortbyTV & sortdirTV should behave as expected

Sharepoint CAML Date query

im getting different results based on the date i use to search on.
Here are the 3 records i want to display, their values for EVENTDATE, and ENDDATE are as follows
1, 2009-08-11T00:00:00Z, 2009-08-14T23:59:59Z
2, 2009-08-11T00:00:00Z, 2009-08-14T23:59:59Z
3, 2009-08-14T20:00:00Z, 2009-08-14T22:00:00Z
When i search for a time between EventDate and EndDate
- 2009-08-14T20:00:00Z, 2009-08-14T22:00:00Z
= i get rows 1,2
- 2009-08-14 T20:00:00Z, 2009-08-14 T22:00:00Z
= i get rows 3
Why does adding a space between the date and time give me a diff result? The entries into the list are the same, the return results dates are the exact same format.
Although the ISO 8601 standard specifies that a space to either side of the T is valid, I would guess that the CAML parser only accepts non spaces. And what you are seeing is a side effect.

Resources