DateTime Stamp as Filename - Progress4gl - progress-4gl

In Progress 4gl,how to use DateTime Stamp as a Filename , such that each time I run a program it should create a new output csv file? Im using Progress version 11.5..For eg., outfilename = "c:\progress\?.csv". Instead of '?' , what should I replace to get a DateTime Stamp as a filename.

This is one way to do what you're looking for:
OUTPUT TO VALUE(REPLACE(REPLACE(ISO-DATE(now), ":", "-"), ".", "-") + ".csv"):
/* output data */
OUTPUT CLOSE.

This is one way of doing it:
OUTPUT TO VALUE("c:\progress\filename_" + STRING(TODAY,"99999999") + STRING(TIME) + ".csv").

Related

Access custom date/time format and input mask error

I have a database that I need to store a bunch of times and do calculations based on the times, however, the times can be over different days so using just a time format wont calculate the correct difference between the two. For ease of use I wanted to limit how much of the date they have to input because there is a bunch of times and I dont want to have to type the full date each time. I created the following custom format: 16-Jan 15:00 (d-mmm h:nn)
I also created a custom input mask to go with this: 90-LLL\ 90:00
My form fields have the same format and input masks to match. The initial input of the field works right, the issue comes when I try to edit a field and change one digit. It pops up with the error that it doesnt match the input mask, even though it does. In order to change the field I have to delete everything, remove focus from the textbox and then click back in. Is there anyway to fix that? Or is there another option to calculate the difference between the times without having to use the date when it could be over 24hrs long (not longer than 48 though)
Yes, you can have a checkbox, NextDay, to mark if the end time is of the following day.
Then your timespan will be:
Dim Timespan As Date
Timespan = CDate([EndTime] - [StartTime] + Abs([NextDay]))
To input the time, you can use the method here: Entering 24-hour time
To format and display your timespan, also for values above 24 hours, use a function like this:
Public Function FormatHourMinute( _
ByVal datTime As Date, _
Optional ByVal strSeparator As String = ":") _
As String
' Returns count of days, hours and minutes of datTime
' converted to hours and minutes as a formatted string
' with an optional choice of time separator.
'
' Example:
' datTime: #10:03# + #20:01#
' returns: 30:04
'
' 2005-02-05. Cactus Data ApS, CPH.
Dim strHour As String
Dim strMinute As String
Dim strHourMinute As String
strHour = CStr(Fix(datTime) * 24 + Hour(datTime))
' Add leading zero to minute count when needed.
strMinute = Right("0" & CStr(Minute(datTime)), 2)
strHourMinute = strHour & strSeparator & strMinute
FormatHourMinute = strHourMinute
End Function

How to display date on a separate line

Question:
I used the custom date format(e.g., 4/22 11:00), and display these dates on the horizontal axis, however I want to split the date format( 4/22 11:00) into two lines,for instance,
4/22
11:00
Why do I want this
Date( 4/22 ) and time(11:00) are displayed at the distinct lines, which can easily differentiate date from time.
What did I try
I found an item "Wrap" in "Alignment", but it can't work.
Better late than ever, if you're still interested, there's a way.
You need to create a new calculated field, to generate the labels as you wish. If the field you're working if is called Date (for instance), you should do:
STR(DAY([Date])) + '/' + STR(MONTH([Date])) + '/' + STR(YEAR([Date]))
+
'
'
+
IF LEN(STR(DATEPART('hour',[Date]))) == 1
THEN '0' + STR(DATEPART('hour',[Date]))
ELSE STR(DATEPART('hour',[Date]))
END
+
':'
+
IF LEN(STR(DATEPART('minute',[Date]))) == 1
THEN '0' + STR(DATEPART('minute',[Date]))
ELSE STR(DATEPART('minute',[Date]))
END
First line is just to get the date on a d/m/y format. Then the trick is to add + '' separated by blank space (tried \n, but it prints "\n" instead of breaking the line)
The second part is to generate the hh:mm (you can use the same logic to get a dd/mm/yyyy format for the date). Basically it adds a zero if the hour or minute is a one digit number.

lua program shows current time

This is a piece of lua script that displays the time. I cannot separate the numbers ie: time.hour, ":",
to basically show hh:mm:ss
time = os.date("*t")
print(time.hour .. time.min .. time.sec)
There are several ways to do this:
Use string concatenation: print(time.hour .. ":" .. time.min .. ":" .. time.sec)
Use formatting: print(("%02d:%02d:%02d"):format(time.hour, time.min, time.sec))
Use table concatenation: print(table.concat({time.hour, time.min, time.sec}, ":"))
When you really need to format your string, my preference would be for #2. For time = {hour = 1, min = 20, sec = 5} this prints:
1:20:5
01:20:05
1:20:5
For simply printing the time - extract what you want (the time) from the full date stamp string:
> os.date():sub(9)
12:30:39
This works on my PC ;). There may be a different date stamp string in your OS.
G
local date = os.date('*t')
local time = os.date("*t")
print(os.date("%A, %m %B %Y | "), ("%02d:%02d:%02d"):format(time.hour, time.min, time.sec))`

Concatenate String and Int to form file name prefix

I am working with PowerShell to create a renaming script for a number of files in a directory.
Two questions here:
I have a string variable $strPrefix = "ACV-100-" and an integer counter $intInc = 000001 and I wish to increment the counter $intInc 1 -> 2 and then concatenate the two and store it in a variable $strCPrefix in the following format: ACV-100-000002.
I believe the $intInc will need to be cast in order to convert it once incrementing is complete but I am unsure how to do this.
Secondly, I have found that the script will display 000001 as 1, 000101 as 101 and so on... I need the full 6 digits to be displayed as this will form a file name. How do I keep or pad the numbers before I process the concatenation?
$intInc = 1
$strCprefix = $strprefix + "{0:000000}" -f $intInc # give ACV-100-000001
hope can help
This should do it:
$intInc = 1
...
$filename = $strPrefix + ('0' * (6 - $intInc.ToSTring().Length)) + ($intInc++).ToString()

How to print date in the format of mm/dd/yyyy in VB

I need to print the date in the format of mm/dd/yyyy.
if the date is 4/24/2009 it should print the date as 04/24/2009.
that is zero padding is also needed..
I used date function to get the current date...but the date is getting in the format of m/dd/yyyy...
Tested in the immediate window and is working for me (output as a comment)
Format(Now, "MM/dd/yyyy") '04/29/2009
Format(Date, "MM/dd/yyyy") '04/29/2009
Format(CStr(Now), "MM/dd/yyyy") '04/29/2009
Format(Date$, "MM/dd/yyyy") '04/29/2009
Format(CDate(Date), "MM/dd/yyyy")'04/29/2009
So whether it is string or datetime should not matter.
Edit: Saw your comment to Fredrik. It doesn't matter how it looks like when you save it to the db table (column date format would be a property of the db and not your program's (or vb's) responsibility). Just format the value as and when you retrieve it from the db.
Note that the "/" character in date formatting functions has a special meaning, as "date separator". This means that i may be replaced with the date separator for the current locale that the program is executed in (here in Sweden it would be replaced with "-" for instance). In order to ensure that you do indeed get the "/" character in the output, I think this would work (I don't have a VB installation to verify with):
Format(date, "MM'/'dd'/'yyyy")
just for the record, escaping the slash will work
Format(dt,"MM\/dd\/yyyy")
Try the next code:
Format(dt,"MM/dd/yyyy")
When you enter date in whatever format it will convert default value so do one thing that in access change your data type date/time to text then it can't affect to your work sure.
I also use VB6 and need to format date in my txt report
this works for me
Format$(Now, "yyyy-mm-dd-00.00.00")
but only if I declare date as string
You can try like this also depending upon your requirement
Dim strDate As String
Dim strDate1() As String
strDate = FormatDateTime(Now, vbGeneralDate)
If InStr(strDate, " ") > 0 Then
strDate1 = Split(strDate, " ")
Dim datDate1 As Date
If Month(strDate1(0)) < 10 Then
txtDate.Text = "0" + strDate1(0)
Else
txtDate.Text = strDate1(0)
End If
Else
End If
Formatting DateTime as a string is straightforward. Often we use format patterns like "HH." But methods like ToShortDateString are also useful.
Example. First we get the current time through DateTime.Now. When you execute these code examples, the current DateTime will be different on your computer.
Here: A format string beginning with MMM (for the month) is used. Look at how the pattern matches up to the output of the program.
VB.NET program that uses format string with DateTime
Module Module1
Sub Main()
' Use current time.
' ... Use a format.
' ... Write to console.
Dim time As DateTime = DateTime.Now
Dim format As String = "MMM ddd d HH:mm yyyy"
Console.WriteLine(time.ToString(format))
End Sub
End Module
Output
Feb Tue 21 13:26 2017
strDate = Format(strDate, "yyyy-mm-dd")
BillTime = Format(BillTime, "hh:mm:ss")