Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Minimal IPC approach?
by
MarkMLl
[
Today
at 09:29:16 pm]
[solved] is there a non v...
by
Martin_fr
[
Today
at 09:13:11 pm]
Custom TRichMemo
by
What I can do
[
Today
at 09:10:10 pm]
IDE crashes and takes so ...
by
Martin_fr
[
Today
at 08:49:04 pm]
Newbie in Web Programming...
by
Nicole
[
Today
at 08:44:50 pm]
multitask question
by
Dzandaa
[
Today
at 08:33:26 pm]
Compiling Lazarus from so...
by
TRon
[
Today
at 07:55:37 pm]
Macos Sequoia Lazarus 3.8...
by
ChrisR
[
Today
at 07:34:39 pm]
Planet generator(raylib)
by
Lulu
[
Today
at 07:29:54 pm]
Good online resource to l...
by
Thaddy
[
Today
at 06:41:21 pm]
TPaintbox picture disappe...
by
TRon
[
Today
at 06:31:33 pm]
login_tty and openpty are...
by
Fred vS
[
Today
at 06:19:14 pm]
ShowModal has a bug in Li...
by
TRon
[
Today
at 04:14:31 pm]
BGRABitmap can't compile
by
Khrys
[
Today
at 03:43:59 pm]
Why isn't Lazarus / Free ...
by
silvercoder70
[
Today
at 02:46:40 pm]
Lazarus Release Candidate...
by
dbannon
[
Today
at 02:02:57 pm]
Linux Laz Packages have i...
by
dbannon
[
Today
at 01:56:35 pm]
Is there a chart displayi...
by
simone
[
Today
at 10:19:27 am]
How to re use a process
by
Thaddy
[
Today
at 10:10:46 am]
Helping beginners
by
Thaddy
[
Today
at 09:15:26 am]
[SOLVED] Application stil...
by
d2010
[
Today
at 07:01:19 am]
TListView - please advis...
by
TRon
[April 29, 2025, 09:49:00 pm]
$CODEPAGE + LCL = Incorre...
by
Thaddy
[April 29, 2025, 06:47:53 pm]
SOLVED: Warning: "crtbegi...
by
Thaddy
[April 29, 2025, 06:43:37 pm]
Randomally generated code
by
Thaddy
[April 29, 2025, 06:41:17 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED]DATEPART fails- New to Lazarus (Read 685 times)
What I can do
Full Member
Posts: 155
[SOLVED]DATEPART fails- New to Lazarus
«
on:
September 01, 2024, 07:33:50 pm »
OS:Windows 10@64
Lazarus:3.22
DB with *.mdb Access@32 bit
Project: Make a new temp Field upon query call
"aYMDate"
but all attempts failed,
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
yyyy
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
ExecSQL
;
SQLQuery1
.
Open
;
«
Last Edit: September 02, 2024, 07:29:36 am by What I can do
»
Logged
tooldeveloper
Newbie
Posts: 5
Re: DATEPART fails- New to Lazarus
«
Reply #1 on:
September 02, 2024, 04:33:46 am »
Try the following instead:
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
Open
;
The 'yyyy' needs two single quotes at beginning and end. The ExecSQL method is only for executing a statement that doesn't return a result.
«
Last Edit: September 02, 2024, 04:44:20 am by tooldeveloper
»
Logged
What I can do
Full Member
Posts: 155
Re: DATEPART fails- New to Lazarus
«
Reply #2 on:
September 02, 2024, 04:55:30 am »
Thank you tooldeveloper
but...
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
Tried two apostrophe and even tried quota but errored out both times
Logged
paweld
Hero Member
Posts: 1361
Re: DATEPART fails- New to Lazarus
«
Reply #3 on:
September 02, 2024, 07:30:39 am »
In MS Access, use quotation marks instead of an apostrophe as a string delimiter
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART("yyyy",ck_Date) as aYMDate From mytable'
;
https://www.w3schools.com/Sql/func_msaccess_datepart.asp
Logged
Best regards / Pozdrawiam
paweld
What I can do
Full Member
Posts: 155
Re: [SOLVED]DATEPART fails- New to Lazarus
«
Reply #4 on:
September 02, 2024, 07:34:22 am »
Thank you, paweld
My problem was bad data.
I needed some working examples so I use ChatGPT to write some and it worked great.
«
Last Edit: September 02, 2024, 07:42:35 am by What I can do
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
TinyPortal
© 2005-2018