Skip to main content
nurcanb61753314
Inspiring
August 17, 2020
Question

how can ı take time for yyyyMMddHHmmss format?

  • August 17, 2020
  • 2 replies
  • 496 views

ı wrote a report at coldfsuion.now ı must sent old information to other company but at sql it is hide '20200817' now ı must add it HHmmss too.how can ı change all data at sql?ı can add random time too.

what will ı add not important but ı must turn all data that format  "yyyyMMddHHmmss" anybody have any idea?

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    August 18, 2020

     

    <cffunction name="formatDatetime" returntype="string">	
    	
    	<!---Default: current date --->
    	<cfargument name="yr" default="#year(now())#">
    	<cfargument name="month" default="#month(now())#">
    	<cfargument name="day" default="#day(now())#">	
    	
    	<cfargument name="hr" default="0">
    	<cfargument name="min" default="0">
    	<cfargument name="sec" default="0">
    	
    	<!--- Construct the datetime from the input --->
    	<cfset var dateTime=createDatetime(arguments.yr, arguments.month, arguments.day, arguments.hr, arguments.min, arguments.sec)>
    	
    	<!--- Express the datetime in the string format yyyyMMddHHmmss (Note: in ColdFusion, nn denotes minutes)--->
    	<cfset var formattedDatetime=datetimeFormat(dateTime, "yyyyMMddHHnnss")>
    	
    	<cfreturn formattedDatetime>
    	
    </cffunction>
    
    <cfoutput>
    <h4>Datetimes in yyyyMMddHHmmss format:</h4>
    Default	datetime (current): #formatDatetime()# <br>
    21st March 2019 15:46:07 : #formatDatetime(2019,3,21,15,46,7)#
    </cfoutput>

     

     

     

    BeRadB
    Inspiring
    August 17, 2020
    Iambradb.com Adobe ColdFusion Specialist.