- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Adds units of time to a date.
Returns
A date/time object.
Category
Function syntax
DateAdd(datepart, number, date)
See also
DateConvert, DatePart, CreateTimeSpan
History
ColdFusion MX 6.1: Added the datepart character L or l to represent milliseconds.
Parameters
Parameter |
Description |
|---|---|
datepart |
String:
|
number |
Number of units of datepart to add to date (positive, to get dates in the future; negative, to get dates in the past). Number must be an integer. |
date |
Date/time object, in the range 100 AD-9999 AD. |
Usage
The datepart specifiers y, d, and w add a number of days to a date.When passing a date/time object as a string, enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object.
Example
<cfscript>
date="{ts '2433-09-01 23:59:59'}";
writeOutput("#date#");
diff=30;
posdateresult=DateAdd("s",diff,date);
writeOutput("#posdateresult#");
</cfscript>
Output
{ts '2433-09-01 23:59:59'}{ts '2433-09-02 00:00:29'}
Real-world examples of using the DateAdd function
eCommerce subscription renewal dates
Calculate subscription renewal dates for different plan types. Automatically set renewal dates when customers purchase subscriptions.
<cfscript>
writeOutput("<h2>1. E-Commerce Subscription Renewal System</h2>");
// Customer subscription start date
subscriptionStart = now();
// Different subscription types with their renewal periods
subscriptionPlans = [
{name: "Monthly Premium", period: "m", duration: 1},
{name: "Quarterly Business", period: "q", duration: 1},
{name: "Annual Enterprise", period: "yyyy", duration: 1},
{name: "Weekly Trial", period: "ww", duration: 1}
];
writeOutput("<p><strong>Subscription Start Date:</strong> " & dateFormat(subscriptionStart, "mm/dd/yyyy") & " " & timeFormat(subscriptionStart, "HH:mm:ss") & "</p>");
writeOutput("<table border='1' cellpadding='5'>");
writeOutput("<tr><th>Plan Type</th><th>Duration</th><th>Renewal Date</th><th>Days Until Renewal</th></tr>");
for (plan in subscriptionPlans) {
renewalDate = dateAdd(plan.period, plan.duration, subscriptionStart);
daysUntilRenewal = dateDiff("d", subscriptionStart, renewalDate);
writeOutput("<tr>");
writeOutput("<td>" & plan.name & "</td>");
writeOutput("<td>" & plan.duration & " " & plan.period & "</td>");
writeOutput("<td>" & dateFormat(renewalDate, "mm/dd/yyyy") & "</td>");
writeOutput("<td>" & daysUntilRenewal & " days</td>");
writeOutput("</tr>");
}
writeOutput("</table><br>");
// Calculate grace period (7 days after renewal)
monthlyRenewal = dateAdd("m", 1, subscriptionStart);
gracePeriodEnd = dateAdd("d", 7, monthlyRenewal);
writeOutput("<p><strong>Grace Period Example:</strong> Monthly renewal on " & dateFormat(monthlyRenewal, "mm/dd/yyyy") & " with grace period ending " & dateFormat(gracePeriodEnd, "mm/dd/yyyy") & "</p>");
</cfscript>
Project management- Calculate deadlines
Calculate project milestones and deadlines based on business days. Automatically set project timelines excluding weekends.
<cfscript>
writeOutput("<hr><h2>2. Project Management Timeline Calculator</h2>");
projectStartDate = createDate(2024, 1, 15); // Monday
// Project phases with business day durations
projectPhases = [
{phase: "Requirements Gathering", businessDays: 5},
{phase: "Design & Architecture", businessDays: 10},
{phase: "Development Sprint 1", businessDays: 15},
{phase: "Development Sprint 2", businessDays: 15},
{phase: "Testing & QA", businessDays: 8},
{phase: "Deployment & Launch", businessDays: 3}
];
writeOutput("<p><strong>Project Start Date:</strong> " & dateFormat(projectStartDate, "mm/dd/yyyy") & " (" & dayOfWeekAsString(dayOfWeek(projectStartDate)) & ")</p>");
writeOutput("<table border='1' cellpadding='5'>");
writeOutput("<tr><th>Phase</th><th>Business Days</th><th>Start Date</th><th>End Date</th><th>Day of Week</th></tr>");
currentDate = projectStartDate;
for (phase in projectPhases) {
phaseStart = currentDate;
// Add business days (multiply by 1.4 to account for weekends approximately)
// More precise method would check each day, but this gives a good estimate
totalDays = ceiling(phase.businessDays * 1.4);
phaseEnd = dateAdd("d", totalDays, phaseStart);
// Adjust if it falls on weekend
while (dayOfWeek(phaseEnd) == 1 OR dayOfWeek(phaseEnd) == 7) {
phaseEnd = dateAdd("d", 1, phaseEnd);
}
writeOutput("<tr>");
writeOutput("<td>" & phase.phase & "</td>");
writeOutput("<td>" & phase.businessDays & "</td>");
writeOutput("<td>" & dateFormat(phaseStart, "mm/dd/yyyy") & "</td>");
writeOutput("<td>" & dateFormat(phaseEnd, "mm/dd/yyyy") & "</td>");
writeOutput("<td>" & dayOfWeekAsString(dayOfWeek(phaseEnd)) & "</td>");
writeOutput("</tr>");
currentDate = dateAdd("d", 1, phaseEnd); // Next phase starts day after
}
writeOutput("</table><br>");
// Calculate project completion
finalDate = dateAdd("d", -1, currentDate);
projectDuration = dateDiff("d", projectStartDate, finalDate);
writeOutput("<p><strong>Total Project Duration:</strong> " & projectDuration & " calendar days</p>");
</cfscript>
Financial system- Payment scheduling
Generate payment schedules for loans, installments, and recurring bills. Calculate due dates for various payment frequencies.
<cfscript>
writeOutput("<hr><h2>3. Financial Payment Scheduling System</h2>");
// Loan details
loanAmount = 50000;
loanStartDate = createDate(2024, 1, 1);
monthlyPayment = 1250;
writeOutput("<p><strong>Loan Details:</strong></p>");
writeOutput("<ul>");
writeOutput("<li>Loan Amount: " & dollarFormat(loanAmount) & "</li>");
writeOutput("<li>Monthly Payment: " & dollarFormat(monthlyPayment) & "</li>");
writeOutput("<li>Start Date: " & dateFormat(loanStartDate, "mm/dd/yyyy") & "</li>");
writeOutput("</ul>");
writeOutput("<h3>Payment Schedule (First 12 months)</h3>");
writeOutput("<table border='1' cellpadding='5'>");
for (i = 1; i <= 12; i++) {
paymentDate = dateAdd("m", i, loanStartDate);
daysFromStart = dateDiff("d", loanStartDate, paymentDate);
writeOutput("<tr>");
writeOutput("<td>" & i & "</td>");
writeOutput("<td>" & dateFormat(paymentDate, "mm/dd/yyyy") & "</td>");
writeOutput("<td>$" & dollarFormat(monthlyPayment) & "</td>");
writeOutput("<td>" & daysFromStart & "</td>");
writeOutput("</tr>");
}
writeOutput("</table><br>");
// Calculate different payment frequencies
writeOutput("<h3>Alternative Payment Frequencies</h3>");
paymentTypes = [
{type: "Weekly", period: "ww", multiplier: 1, amount: 288},
{type: "Bi-Weekly", period: "ww", multiplier: 2, amount: 577},
{type: "Quarterly", period: "q", multiplier: 1, amount: 3750},
{type: "Semi-Annual", period: "m", multiplier: 6, amount: 7500}
];
writeOutput("<table border='1' cellpadding='5'>");
writeOutput("<tr><th>Payment Type</th><th>Next Due Date</th><th>Amount</th><th>Following Date</th></tr>");
for (payment in paymentTypes) {
nextDue = dateAdd(payment.period, payment.multiplier, loanStartDate);
followingDue = dateAdd(payment.period, payment.multiplier, nextDue);
writeOutput("<tr>");
writeOutput("<td>" & payment.type & "</td>");
writeOutput("<td>" & dateFormat(nextDue, "mm/dd/yyyy") & "</td>");
writeOutput("<td>$" & dollarFormat(payment.amount) & "</td>");
writeOutput("<td>" & dateFormat(followingDue, "mm/dd/yyyy") & "</td>");
writeOutput("</tr>");
}
writeOutput("</table><br>");
</cfscript>
Event management- Scheduling and reminders
Event planning system with automated reminder scheduling. Calculate reminder dates and event scheduling for different time zones.
<cfscript>
writeOutput("<hr><h2>4. Event Management & Reminder System</h2>");
// Main event details
eventDate = createDateTime(2024, 6, 15, 14, 30, 0); // June 15, 2024, 2:30 PM
eventName = "Annual Company Conference";
writeOutput("<p><strong>Event:</strong> " & eventName & "</p>");
writeOutput("<p><strong>Event Date & Time:</strong> " & dateFormat(eventDate, "mm/dd/yyyy") & " at " & timeFormat(eventDate, "h:mm tt") & "</p>");
// Calculate reminder schedule
reminderSchedule = [
{name: "Save the Date", days: -90, timeUnit: "d"},
{name: "Early Bird Registration", days: -60, timeUnit: "d"},
{name: "Final Registration Reminder", days: -30, timeUnit: "d"},
{name: "One Week Notice", days: -7, timeUnit: "d"},
{name: "Day Before Reminder", days: -1, timeUnit: "d"},
{name: "Day of Event - Morning", hours: -4, timeUnit: "h"},
{name: "Event Starts Soon", minutes: -30, timeUnit: "n"}
];
writeOutput("<h3>Automated Reminder Schedule</h3>");
writeOutput("<table border='1' cellpadding='5'>");
writeOutput("<tr><th>Reminder Type</th><th>Send Date</th><th>Send Time</th><th>Days Until Event</th></tr>");
for (reminder in reminderSchedule) {
if (structKeyExists(reminder, "days")) {
reminderDate = dateAdd(reminder.timeUnit, reminder.days, eventDate);
} else if (structKeyExists(reminder, "hours")) {
reminderDate = dateAdd(reminder.timeUnit, reminder.hours, eventDate);
} else if (structKeyExists(reminder, "minutes")) {
reminderDate = dateAdd(reminder.timeUnit, reminder.minutes, eventDate);
}
daysUntilEvent = dateDiff("d", reminderDate, eventDate);
writeOutput("<tr>");
writeOutput("<td>" & reminder.name & "</td>");
writeOutput("<td>" & dateFormat(reminderDate, "mm/dd/yyyy") & "</td>");
writeOutput("<td>" & timeFormat(reminderDate, "h:mm tt") & "</td>");
writeOutput("<td>" & daysUntilEvent & "</td>");
writeOutput("</tr>");
}
writeOutput("</table><br>");
// Multi-day event scheduling
writeOutput("<h3>Multi-Day Conference Schedule</h3>");
conferenceDays = [
{day: "Pre-Conference Workshop", dayOffset: -1, startTime: "09:00"},
{day: "Main Conference Day 1", dayOffset: 0, startTime: "08:30"},
{day: "Main Conference Day 2", dayOffset: 1, startTime: "08:30"},
{day: "Post-Conference Networking", dayOffset: 2, startTime: "18:00"}
];
writeOutput("<table border='1' cellpadding='5'>");
writeOutput("<tr><th>Event Day</th><th>Date</th><th>Start Time</th><th>Day of Week</th></tr>");
for (day in conferenceDays) {
dayDate = dateAdd("d", day.dayOffset, eventDate);
writeOutput("<tr>");
writeOutput("<td>" & day.day & "</td>");
writeOutput("<td>" & dateFormat(dayDate, "mm/dd/yyyy") & "</td>");
writeOutput("<td>" & day.startTime & "</td>");
writeOutput("<td>" & dayOfWeekAsString(dayOfWeek(dayDate)) & "</td>");
writeOutput("</tr>");
}
writeOutput("</table><br>");
</cfscript>
