Click or drag to resize

Date2Bin Function

X#
Convert a date to a 32-bit binary date string.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION Date2Bin(
	dValue AS DATE
) AS STRING
Request Example View Source

Parameters

dValue
Type: Date
The date value to convert.

Return Value

Type: String
Remarks
Date2Bin() is a conversion function that converts a date data type into a 4-byte string. Typical applications include reading foreign file types in their native format and then saving, reading, decrypting, and transmitting date types in their compressed binary form instead of in strings.
Its inverse is Bin2Date().
Examples
This example uses Date2Bin() to record today's date to a debugging file:
X#
 1FUNCTION RecordDate() AS LOGIC
 2    LOCAL nh
 3    LOCAL lSuccess := FALSE AS LOGIC
 4    nh := FOpen2("debug.doc", FO_READWRITE)
 5    // Assumes that file debug.doc already exists
 6    IF nh != F_ERROR
 7        FWrite(nh, Date2Bin(Today()))
 8        FClose(nh)
 9        lSuccess := TRUE
10    ELSE
11        ? "An error occurred when opening debug.doc"
12        ? FError()
13    ENDIF
14    RETURN lSuccess
See Also