Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Date Type

Updated on 2024-05-07 GMT+08:00

Table 1 lists the common date type APIs provided by ecpg.

Table 1 Common date type APIs

API

Description

Remarks

date* PGTYPESdate_new(void)

Returns a pointer to an allocated date variable.

This function creates a date variable on the heap. The return value is of the date* type.

void PGTYPESdate_free(date*)

Releases the memory that has been allocated to a date variable.

Frees a date* variable created using the PGTYPESdate_free function.

date PGTYPESdate_from_asc(char* str, char** endptr)

Parses a date from its textual representation.

This function accepts a C string str and a pointer to a C string endptr. ecpg converts the date expressed in text into a character string. Currently, ECPG does not support storing the address of the first invalid character in *endptr. However, endptr can be set to null.

Note that the function always assumes MDY-formatted dates and there is currently no variable to change that within ecpg.

char* PGTYPESdate_to_asc(date dDate)

Returns the textual representation of a date variable.

This function accepts the date dDate as its unique parameter. It will output the date in the YYYY-MM-DD format.

date PGTYPESdate_from_timestamp(timestamp dt)

Extracts the date part from a timestamp.

This function accepts a timestamp as its unique parameter and returns the extracted date part from the timestamp.

void PGTYPESdate_julmdy(date jd, int* mdy)

Extracts the values of day, month, and year from a variable of the date type.

This function accepts the date jd and a pointer to an array of three integer values mdy. The variable name indicates the sequence. mdy[0] indicates the month, mdy[1] indicates the day, and mdy[2] indicates the year.

void PGTYPESdate_mdyjul(int* mdy, date* jdate)

Creates a date using the specified integer value.

This function accepts an array consisting of three integers (mdy) as its first parameter. The three integers are used to indicate the day, month, and year, respectively. The second parameter is a pointer to a variable of the date type, which is used to store the result of the operation.

int PGTYPESdate_dayofweek(date d)

Returns a number indicating the day of a week for a date value.

This function accepts the date variable d as its unique parameter and returns an integer indicating the day of the week.

void PGTYPESdate_today(date* d)

Returns the current date.

This function accepts a pointer to a date variable d and sets the parameter to the current date.
  • 0: Sunday
  • 1: Monday
  • 2: Tuesday
  • 3: Wednesday
  • 4: Thursday
  • 5: Friday
  • 6: Saturday

int PGTYPESdate_defmt_asc(date* d, const char* fmt, char* str)

Converts a C char* string to a value of the date type using a format mask.

This function accepts a pointer d pointing to a date value for storing the operation result, a format mask fmt for parsing the date, and a C char* string str containing the textual representation of the date. The textual representation is expected to match the format mask. However, you do not need to have a 1:1 mapping of the string to the format mask. The function only analyzes the sequential order and looks for the literals "yy" or "yyyy" that indicate the position of the year, "mm" indicating the position of the month and "dd" indicating the position of the day.

Example of valid input (fmt, str):

yy/mm/dd 1994, February 3rd

int PGTYPESdate_fmt_asc(dat dDate, const char* fmtstring, char* outbuf)

Converts a variable of the date type into its textual representation using a format mask.

This function accepts the date dDate to be converted, the format mask fmtstring, and the string outbuf of the textual representation of the date to be saved.

The function returns 0 on success and a negative value in case of error.

Example of valid input:
112359            //mmddyy
59/11/23          //yy/mm/dd
Nov.23,1959       //mmm.dd,yyyy
Mon,Nov.23,1959   //ddd,mmm.dd,yyyy
Format:
  • dd: indicates the day of a month.
  • mm: indicates the month of a year.
  • yy: indicates a two-digit year.
  • yyyy: indicates a four-digit year.
  • ddd: indicates the day of a week.
  • mmm: indicates the month.

Examples

For details, see Examples.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback